﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

namespace DataStudio
{
    public partial class Loader : Form
    {
        public string file;
        public string type;
        public Loader(string file, string type)
        {
            InitializeComponent();
            this.file = file;
            this.type = type;
        }

        private void Loader_Load(object sender, EventArgs e)
        {
            try
            {
                string path = Environment.CurrentDirectory + "\\" + this.file + ".dll";

                Assembly asm = Assembly.LoadFile(path);
                object obj = asm.CreateInstance(this.type);
                UserControl usl = (UserControl)obj;
                //usl.Width = this.Width;
                //usl.Height = this.Height;
                usl.Dock = DockStyle.Fill;
                this.Controls[0].Controls.Add(usl);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void Loader_FormClosed(object sender, FormClosedEventArgs e)
        {
            Modules.RemoveTap(this.type);
        }
    }
}
